home *** CD-ROM | disk | FTP | other *** search
- /* Some extra routines which may be useful... */
- /* They are for implementing a non-standard rectangle type, i.e. */
- /* when you call Shell_AddRectangle yourself instead of */
- /* Shell_AddBarGraph, Shell_AddGeneralArray, ... etc. When you do this */
- /* you have to write a redrawing function, for which many of the */
- /* following functions are useful. */
- /* The supplied rectangle funtions such as BarGraph, Array etc. use */
- /* these functions, so look at the source for examples. */
-
-
- #ifndef __Shell_Extra_h
- #define __Shell_Extra_h
-
- #ifndef __Shell_h
- #include "Shell.Shell.h"
- #endif
-
- #ifndef __dl_gfx_h
- #include "DeskLib:GFX.h"
- #endif
-
- #ifndef __dl_colourtrans_h
- #include "DeskLib:ColourTran.h"
- #endif
-
-
- BOOL Shell_CheckYScrollIsBottom( window_handle windowhandle);
- /* Returns TRUE if windowhandle y-scrollbar is at bottom */
-
- void Shell_MoveYScrollToBottom( window_handle window);
- /* Moves y-scrollbar to bottom */
-
- #define Shell_MakeGE( a, b) if ((b) > (a)) (a) = (b)
- #define Shell_MakeLE( a, b) if ((b) < (a)) (a) = (b)
- /* These macros change the *first* parameter so that it */
- /* is >= or <= the second parameter. */
- /* Useful when you are clipping rectangles. */
-
-
- void Shell_ConvertToTextRect( wimp_rect *rect);
- /* divides all x's and y's by Shell_TEXTXSIZE, Shell_TEXTYSIZE */
-
- void Shell_ConvertToSubTextRect( wimp_rect *rect, const wimp_rect *bigrect);
- /* Used in 2D array rectangle routines. */
- /* bigrect encloses total array, this routine makes *rect */
- /* contain line and column of rect inside bigrect */
-
- void Shell_ConvertToSubTextRect2( wimp_rect *rect, wimp_point rectsize);
- /* As above, but uses a size for the bigrect, for the new */
- /* redrawing method where the redrawer works relative to the */
- /* bottom-left of the rectblock. */
-
-
-
-
- void Shell_CheckWindSizeAndRedraw( window_handle window, const wimp_rect *rect);
- /* Checks that *rect is inside current size of window, and */
- /* resizes the window if nessary. Then does a Wimp_ForceRedraw */
- /* if any of rect is currently visible, or the window has been */
- /* resized. */
- /* This is used by Shell_AddRectangle. */
-
- void Shell_CheckWindSizeAndRedrawAndScroll( window_handle window, const wimp_rect *rect);
- /* As above, but also keeps scroll at lower limit if it is */
- /* already there */
-
- void Shell_ResizeIconRect( Shell_rectblock *r);
- /* Makes a rect's icon-rect the appropriate size */
- /* for the rect's rect. This function should be called */
- /* whenever a rect is resized. */
- /* When redrawing rects, the iconrect is checked */
- /* against the redraw rect so that any icon-border */
- /* is redrawn correctly. */
-
-
-
-
- /* Low level routines for use in rectangle redrawing functions */
- /* ----------------------------------------------------------- */
- /* They enable you to print text, fill rectangles etc inside windows, */
- /* but without having to convert everything to screen coors. */
-
-
- /* These next few functions/#defines are equivalent to GFX_ calls, */
- /* except you pass them a convert_block, and they deal with the scroll */
- /* bars, window position, etc. */
-
-
- #define Shell_ConvertXToScreen( xx, convert) ( (xx) + (convert).x)
- #define Shell_ConvertYToScreen( yy, convert) ( (yy) + (convert).y)
-
- #define Shell_ConvertXToWorkarea( xx, convert) ( (xx) - (convert).x)
- #define Shell_ConvertYToWorkarea( yy, convert) ( (yy) - (convert).y)
-
- #define Shell_ConvertRectToWorkarea( rect, convert) { \
- (rect)->min.x -= (convert).x; \
- (rect)->max.x -= (convert).x; \
- (rect)->min.y -= (convert).y; \
- (rect)->max.y -= (convert).y; \
- } \
-
- #define Shell_ConvertRectToScreen( rect, convert) { \
- (rect)->min.x += (convert).x; \
- (rect)->max.x += (convert).x; \
- (rect)->min.y += (convert).y; \
- (rect)->max.y += (convert).y; \
- } \
-
-
- void Shell_RectangleFill( const wimp_rect *rect, Shell_convertpoint convert);
-
- void Shell_RectangleFill3( int x, int y, int width, int height, Shell_convertpoint convert);
-
- void Shell_RectangleFill2( int xmin, int ymin, int xmax, int ymax, Shell_convertpoint convert);
-
-
-
- #define Shell_RectangleFill_16bit( rect, convert) \
- GFX_RectangleFill( \
- Shell_ConvertXToScreen( rect->min.x, convert), \
- Shell_ConvertYToScreen( rect->min.y, convert), \
- rect->max.x - rect->min.x, \
- rect->max.y - rect->min.y \
- ) \
-
-
-
- #define Shell_RectangleFill2_16bit( xmin, ymin, xmax, ymax, convert) \
- GFX_RectangleFill( \
- Shell_ConvertXToScreen( xmin, convert), \
- Shell_ConvertYToScreen( ymin, convert), \
- xmax - xmin, \
- ymax - ymin \
- ) \
-
-
- #define Shell_RectangleFill3_16bit( xmin, ymin, width, height, convert) \
- GFX_RectangleFill( \
- Shell_ConvertXToScreen( xmin, convert), \
- Shell_ConvertYToScreen( ymin, convert), \
- width, \
- height \
- ) \
-
-
- #define Shell_GFX_ParallelFill( x1, y1, x2, y2, x3, y3) \
- do { \
- GFX_Move( x1, y1); \
- GFX_Move( x2, y2); \
- GFX_Plot( plot_DRAWABSFORE + plot_PARALLELFILL, x3, y3); \
- } \
- while (0) \
- /* See below. */
-
- #define Shell_GFX_ParallelFillBy( x1, y1, dx2, dy2, dx3, dy3) \
- do { \
- GFX_Move( x1, y1); \
- GFX_MoveBy( dx2, dy2); \
- GFX_Plot( plot_DRAWRELFORE + plot_PARALLELFILL, dx3, dy3); \
- } \
- while (0) \
- /* See below. */
-
-
- #define Shell_ParallelFill( x1, y1, x2, y2, x3, y3, convert) \
- Shell_GFX_ParallelFill( \
- Shell_ConvertXToScreen( x1, convert), \
- Shell_ConvertYToScreen( y1, convert), \
- Shell_ConvertXToScreen( x2, convert), \
- Shell_ConvertYToScreen( y2, convert), \
- Shell_ConvertXToScreen( x3, convert), \
- Shell_ConvertYToScreen( y3, convert) \
- ) \
- /* Draws a parallelogram with (x1,y1) and (x3,y3) being opposite corners */
- /* and (x2,y2) one of the other corners. */
-
- #define Shell_ParallelFillBy( x1, y1, dx2, dy2, dx3, dy3, convert) \
- Shell_GFX_ParallelFillBy( \
- Shell_ConvertXToScreen( x1, convert), \
- Shell_ConvertYToScreen( y1, convert), \
- dx2, dy2, \
- dx3, dy3 \
- ) \
- /* Draws a parallelogram with one corner being (x1,y1), one of its neighbers */
- /* being (x1+dx2,y1+dy2), and the opposite corner to (x1,y1) being */
- /* (x1+dx2+dx3,y1+dy2+dy3). */
-
-
-
- #define Shell_Draw2( x, y, convert) \
- GFX_Draw( \
- Shell_ConvertXToScreen( x, convert), \
- Shell_ConvertYToScreen( y, convert) \
- ) \
-
- #define Shell_Move( x, y, convert) \
- GFX_Move( \
- Shell_ConvertXToScreen( x, convert), \
- Shell_ConvertYToScreen( y, convert) \
- ) \
-
-
-
- #define Shell_PlotPoint( x, y, convert) \
- GFX_PlotPoint( \
- Shell_ConvertXToScreen( x, convert), \
- Shell_ConvertYToScreen( y, convert) \
- ) \
-
-
- #define Shell_Circle( x, y, r, convert) \
- GFX_Circle( \
- Shell_ConvertXToScreen( x, convert), \
- Shell_ConvertYToScreen( y, convert), \
- r \
- ) \
-
- #define Shell_CircleFill( x, y, r, convert) \
- GFX_CircleFill( \
- Shell_ConvertXToScreen( x, convert), \
- Shell_ConvertYToScreen( y, convert), \
- r \
- ) \
-
-
-
-
-
- #define Shell_Plot( plotcode, x, y, convert) \
- GFX_Plot( \
- plotcode, \
- Shell_ConvertXToScreen( x), \
- Shell_ConvertYToScreen( y) \
- ) \
-
- /* A general OS_Plot routine */
-
-
-
- /*
- void Shell_PrintString( const char *s, int x, int y, const Shell_convertpoint convert);
- */
- /* Low level non-wimp print routine to print text straight */
- /* onto screen. x and y should be in work-area coors. */
- /* Used in rectangle-redrawing routines to print text without */
- /* having to convert explicitly to screen coors. */
-
- #define Shell_PrintString( text, x, y, convert) \
- do { \
- GFX_Move( \
- Shell_ConvertXToScreen( x, convert), \
- Shell_ConvertYToScreen( y, convert) - Shell_PIXELYSIZE \
- ); \
- GFX_Write0( text); \
- } \
- while (0) \
-
- /* The do...while bit is so Shell_PrintString looks like a real function. */
- /* i.e. you put a semicolon after it. */
-
-
-
- void Shell_ConvertToSubRect( wimp_rect *rect, const wimp_rect *bigrect);
-
- void Shell_ConvertToSubRect2( wimp_rect *rect, wimp_point bigsize);
-
-
- #define Shell_SetGreyGCOL( x) \
- ColourTrans_SetGCOL( \
- (( (int) ((x)*255.999)) << 8) | \
- (( (int) ((x)*255.999)) << 16) | \
- (( (int) ((x)*255.999)) << 24), \
- 1<<8, /* Use ECFs */ \
- 0 /* gcol action */ \
- ) \
- /* 'x' should be a brightness between 0 and 1. This uses a */
- /* ColourTrans call to set the GCOL colour to a grey of the */
- /* appropriate brightness. */
- /* It should be fairly obvious how it works... */
-
-
-
- #endif
-